package com.feng.stateAnalysis
{
	import com.feng.ControllerCenter;
	import com.feng.model.Player;
	import com.feng.utils.ChallengeCompute;

	/**
	 * 多人形势分析
	 * @author 风之守望者
	 * 2013-4-2
	 */
	public class MultiplayerAnalysis extends AnalysisBase
	{
		/** 按攻击降序排列 */
		public var attackSortList:Vector.<Player>;

		/** 按防御降序排列 */
		public var defenseSortList:Vector.<Player>;

		/** 按攻速降序排列 */
		public var speedSortList:Vector.<Player>;

		/** 按血量升序排列 */
		public var hpSortList:Vector.<Player>;
		
		/** 战斗力降序排列 */
		public var powerfulSortList:Array;
		

		public function MultiplayerAnalysis(controllerCenter:ControllerCenter)
		{
			super(controllerCenter);
		}

		override public function analysis():void
		{
			attackSortList = enemyList.concat();
			attackSortList.push(me);
			attackSortList.sort(function compare(x:Player, y:Player):Number
			{
				return y.attack - x.attack;
			});

			speedSortList = attackSortList.concat();
			speedSortList.sort(function compare(x:Player, y:Player):Number
			{
				return y.speed - x.speed;
			});

			defenseSortList = attackSortList.concat();
			defenseSortList.sort(function compare(x:Player, y:Player):Number
			{
				return y.defense - x.defense;
			});

			hpSortList = attackSortList.concat();
			hpSortList.sort(function compare(x:Player, y:Player):Number
			{
				return x.hp - y.hp;
			});

			powerfulSortList = [];
			for each (var player:Player in enemyList)
			{
				var enemyChallengeValue:Number = ChallengeCompute.fastChallenge(player, me);
				powerfulSortList.push({value: enemyChallengeValue, player: player});
			}
			powerfulSortList.push({value: 0, player: me});
			powerfulSortList.sortOn("value", Array.NUMERIC | Array.DESCENDING);

		}
	}
}
